package com.sacc.controller;

import com.power.common.model.CommonResult;
import com.sacc.mapper.AddrUserMapper;
import com.sacc.pojo.AddrUser;
import com.sacc.service.AddrUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 滚~韬
 * @date 2022/4/9 14:52
 */
@RestController
@RequestMapping("/user/address")
public class AddrUserController {

    @Autowired
    private AddrUserService addrUserService;

    /**
     * 更新用户地址
     * @param addrUser
     */
    @PostMapping("/update")
    private CommonResult Update(@RequestBody AddrUser addrUser){
        return addrUserService.Update(addrUser);
    }

    /**
     * 增加用户地址
     * @param addrUser
     * @return
     */
    @PostMapping("/add")
    private CommonResult Add(@RequestBody AddrUser addrUser){
        return addrUserService.Add(addrUser);
    }

    /**
     * 得到用户地址
     * @param openId
     * @return
     */
    @GetMapping("/get")
    private List<AddrUser> Get(@RequestParam String openId){
        return addrUserService.Get(openId);
    }

    /**
     * 删除用户地址
     * @param id
     * @return
     */
    @PostMapping("/delete")
    private CommonResult Delete(@RequestParam String id){
        return addrUserService.Delete(id);
    }

    /**
     * 删除用户地址
     * @param openId
     * @return
     */
    @GetMapping("/getdefault")
    private AddrUser GetDefault(@RequestParam String openId){
        return addrUserService.getDefault(openId);
    }
}
